Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve external-name config of iot thing type #1456

Merged
merged 2 commits into from
Nov 1, 2024

Conversation

mbbush
Copy link
Collaborator

@mbbush mbbush commented Aug 9, 2024

Description of your changes

The aws iot ThingType resource uses a parameter called "name" as its terraform id. Unfortunately, when it was first implemented, it was done using IdentifierFromProvider, which means that creating a new managed resource always attempts to create a new external resource, even if there already is one with the same name. For this particular resource, this results in errors from the AWS api.

The best external name config would be config.NameAsIdentifier, which would remove the redundant name property from both spec.forProvider and spec.initProvider, and initialize the name from metadata.name. But that's a breaking api change.

The next best external name config would be config.TemplatedStringAsIdentifier("", "{{ .parameters.name }}"), but that will (correctly) set name as an identifier field, which will remove it from spec.initProvider, which is also a breaking change.

So this is the best I can do at the moment without changing the schema. The content of the external name remains the same, but now crossplane knows how to construct it from the spec, so it can check for resource existence before trying to create it.

Because name is part of the id, but not set as an identifier field, various edge cases where the user omits it may continue to fail in less-than-ideal ways, but that's not a change from current behavior.

Fixes #

I have:

  • Read and followed Crossplane's contribution process.
  • Run make reviewable to ensure this PR is ready for review.
  • Added backport release-x.y labels to auto-backport this PR if necessary.

How has this code been tested

Running uptest on the pr.

Manually confirming that the external name is the in the same format both before and after this change.

@mbbush
Copy link
Collaborator Author

mbbush commented Aug 9, 2024

/test-examples="examples/iot/v1beta1/thingtype.yaml"

@mbbush
Copy link
Collaborator Author

mbbush commented Aug 9, 2024

/test-examples="examples/iot/v1beta2/thingtype.yaml"

@mbbush
Copy link
Collaborator Author

mbbush commented Aug 9, 2024

/test-examples="examples/iot/v1beta1/thingtype.yaml,examples/iot/v1beta2/thingtype.yaml"

@mbbush mbbush marked this pull request as ready for review August 9, 2024 20:30
@turkenf
Copy link
Collaborator

turkenf commented Nov 1, 2024

/test-examples="examples/iot/v1beta2/thingtype.yaml"

@turkenf
Copy link
Collaborator

turkenf commented Nov 1, 2024

/test-examples="examples/iot/v1beta1/thingtype.yaml"

Copy link
Collaborator

@turkenf turkenf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @mbbush, LGTM.

@turkenf turkenf merged commit 2aa45e3 into crossplane-contrib:main Nov 1, 2024
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants